#!./perl

# ------------------------------------------------------------

# devinfo.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
# This allows the development Kit to choose what
# page to load depending on the existence of .devkit

# ------------------------------------------------------------

# Bugs and other fixes

# ------------------------------------------------------------
$DEVINFONAME=".devkit";
sub ComputeDevinfo
{
	$BASEDIR = $ENV{"DOCUMENT_ROOT"};
	$Devinfo=$BASEDIR . "/" . $DEVINFONAME;
}

sub PrintDevinfo
{
	local($compdir, $status) = @_;

	&ComputeDevinfo();
	open(DEVINFO, ">$Devinfo");
	#open(DEVINFO, ">$Devinfo") || die("Cannot open $Devinfo\n");

	$old = select(DEVINFO);
	print "$compdir^$status\n";
	close(DEVINFO);
	chmod(0666, $DevInfo);
	select($old);
}

sub GetDevinfo
{
	local($infoReq) = @_;
	&ComputeDevinfo();
	open(DEVINFO, "<$Devinfo");
	#open(DEVINFO, "<$Devinfo") || die("Cannot read $Devinfo\n");
	@Info = split(/\^/, <DEVINFO>);
	if ($infoReq eq "dir") {
		$Info[0];
	} elsif ($infoReq eq "status") {
		$Info[1];
	}
}
